﻿/****************************************************************************************
*	Mouzetrap - client/server framework	
*
*	$HeadURL: http://mouzetrap.googlecode.com/svn/trunk/Mouzetrap/Network/IPacket.cs $
*	$Id: IPacket.cs 11 2009-06-11 09:10:25Z tobz@fallenrealms.net $
* 
*	Copyright (c) 2008 Toby Lawrence
* 
*	Permission is hereby granted, free of charge, to any person obtaining a copy
*	of this software and associated documentation files (the "Software"), to deal
*	in the Software without restriction, including without limitation the rights
*	to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
*	copies of the Software, and to permit persons to whom the Software is
*	furnished to do so, subject to the following conditions:
* 
*	The above copyright notice and this permission notice shall be included in
*	all copies or substantial portions of the Software.
* 
*	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
*	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
*	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
*	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
*	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
*	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
*	THE SOFTWARE.
* 
****************************************************************************************/

namespace Mouzetrap.Network
{
	/// <summary>
	/// Defines the interface of a packet.  A packet is an field-oriented representation of binary data.
	/// </summary>
	/// <remarks>
	/// Typically, packet interfaces/classes are defined with directionality in mind.  These types 
	/// are then coupled with rigid implementations of handling code.  The point of this interface is to allow 
	/// a single interface to be consumed, where there is enough metadata to determine, by direction, what type
	/// the object is, thus allowing more generic consumption of any packet objects, removing the need for a
	/// rigid implementation.
	/// </remarks>
	public interface IPacket
	{
		/// <summary>
		/// The ID of the packet.
		/// </summary>
		/// <remarks>This is most typically a unique number that identifies a specific type of packet.</remarks>
		int PacketId { get; }

		/// <summary>
		/// The direction of the packet. (client to server, server to client)
		/// </summary>
		PacketDirection Direction { get; }

		/// <summary>
		/// Gets all the data from the packet.
		/// </summary>
		/// <returns>a byte array of the data</returns>
		byte[] GetPacketData();
	}
}